package com.bw.classfiy.mvvm.viewmodel;

import com.bw.classfiy.mvvm.adapter.ParticularsAdapter;
import com.bw.classfiy.mvvm.model.ClassFiyModel;
import com.bw.mvvm.entity.ClassFiyEntity;
import com.bw.mvvm.entity.BaseEntity;
import com.bw.mvvm.mvvm.viewmodel.BaseViewModel;
import com.bw.mvvm.entity.CartEntity;
import com.chad.library.adapter.base.BaseQuickAdapter;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;
import okhttp3.RequestBody;

public class  ParticulareViewModel extends BaseViewModel<ClassFiyModel> {

    public BaseQuickAdapter adapter = new ParticularsAdapter();
    public List<CartEntity.DataBean> cartEntities = new ArrayList<>();
    @Override
    protected void result(BaseEntity entity) {
        if (entity instanceof ClassFiyEntity){
            ClassFiyEntity classFiyEntity = (ClassFiyEntity) entity;
            adapter.setNewInstance(classFiyEntity.getData());
            for (ClassFiyEntity.DataBean datum : classFiyEntity.getData()) {
                ClassFiyEntity.DataBean dataBean = new ClassFiyEntity.DataBean();

//                cartEntities.add()
            }
        }
//        adapter.setOnItemChildClickListener(new OnItemChildClickListener() {
//            @Override
//            public void onItemChildClick(@NonNull @NotNull BaseQuickAdapter adapter, @NonNull @NotNull View view, int position) {
//                EventBus.getDefault().post();
//            }
//        });
    }

    @Override
    public void onCreate() {
        super.onCreate();
        HashMap<String,Object> map = new HashMap<>();
        map.put("parentId",2);
        RequestBody body = m.createBody(map);
        m.requestValue(body).subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(this);
    }
}
